package com.kandinfo.base.security.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.kandinfo.base.security.domain.Role;

public interface RoleRepository extends JpaRepository<Role, Long>,
JpaSpecificationExecutor<Role>{
    Role findRoleById( Long id);
    Role findRoleByroleName(String name);
    
    @Query(value = "select * from role where role_name = ?1", nativeQuery = true)
    List<Role> findRole(String roleName);
    
    @Query(value = "select * from role where role_name not like '%admin%'", nativeQuery = true)
    List<Role> findRoleNotAdmin();
    /**
     * 
    * Description: check name
    *
    * @param roleName
    * @param roleDesc
    * @return
     */
    @Query(value = "select * from role where id != ?1 and role_name = ?2 ", nativeQuery = true)
    List<Role> checkName(Long id,String roleName);
}
